package com.amoqi.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.PathKit;
import com.jfinal.upload.UploadFile;

public class FileController extends Controller {
	public void index(){
		render("index.jsp");
	}
	/**
	 * 普通form上传
	 */
	public void formNormal(){
		UploadFile file = getFile("file1");
		setAttr("msg","调用文件上传FileController:");
		//setAttr("urlPath",PathKit.getWebRootPath()+"amoqiUpload/"+file.getFileName());
		setAttr("filePath",file.getUploadPath()+"\\"+file.getFileName());
		setAttr("urlPath","amoqiUpload/"+file.getFileName());
		renderJsp("result.jsp");
	}
	public void formwithparam(){
		UploadFile file = getFile("file1");
		String param = getPara("param");
		setAttr("msg","调用文件上传FileController:formwithparam 参数值是:"+param);
		setAttr("filePath",file.getUploadPath()+"\\"+file.getFileName());
		setAttr("urlPath","amoqiUpload/"+file.getFileName());
		renderJsp("result.jsp");
	}
	/**
	 * ajax  form上传
	 */
	public void ajaxForm4(){
		UploadFile file = getFile("file1");
		setAttr("msg","调用文件上传FileController:ajaxForm4");
		setAttr("filePath",file.getUploadPath()+"\\"+file.getFileName());
		setAttr("urlPath","amoqiUpload/"+file.getFileName());
		renderJson();
	}
	/**
	 * ajax  form上传
	 */
	public void ajaxForm5(){
		UploadFile file = getFile("file1");
		setAttr("参数",getPara("param"));
		setAttr("msg","调用文件上传FileController:ajaxForm5");
		setAttr("filePath",file.getUploadPath()+"\\"+file.getFileName());
		setAttr("urlPath","amoqiUpload/"+file.getFileName());
		renderJson();
	}
}
